<template>
</template>

<script>
  // vuex的学习
  import Vuex from "vuex";
  import Vue from 'vue'
  Vue.use(Vuex)

  const store = new Vuex.Store({
    state: {
      count: 0
    },
    mutations: {
      increment (state) {
        state.count++
      }
    }
  })
  export default {
    name: "index2",
    store,
    methods: {
      increment() {
        this.$store.commit('increment')
        console.log(this.$store.state.count)
      }
    },
    created() {
      this.increment()
      this.increment()
      this.increment()
    }
  }

</script>

<style scoped>

</style>
